home *** CD-ROM | disk | FTP | other *** search
-
- DOS & Don'ts -- Part 29
- by Jimmy Weiler
-
-
- ======================================
- Now even YOUR programs can read the
- directory.
- ======================================
-
-
- We haven't said much about the
-
- directory since Part 7.
-
- I am just going to assume that you
-
- all know how to LOAD "$",8 then LIST
-
- to look at what files are on your
-
- disk. This installment of DOS &
-
- Don'ts will show you how to make your
-
- PROGRAMS read and display a directory.
-
- This time, I break with tradition
-
- and show you the simple way to do it
-
- first.
-
- 1. Install the DOS wedge.
-
- 2. Where you want your program to
- display the directory, enter this
- instruction: @"$"
-
-
- You can get fancy with the wedge:
-
- To display only the SEQ files: @"$*=S"
-
- To display only the PRG files: @"$*=P"
-
- To display only the REL files: @"$*=R"
-
- To display only the USR files: @"$*=U"
-
- To display only files beginning with
-
- any pattern, use the wild card, "*".
-
- @"$T.*" will show only files prefixed
-
- by "T."
-
- You can mix these concepts, too:
-
- @"$TEXT*=S" will show only those
-
- sequential files whose names start
-
- with "TEXT".
-
- Okay, enough of the easy stuff. Now
-
- I'll show you the hard way to do the
-
- same thing.
-
- The 1541 User's Manual says you can
-
- read the directory just like a
-
- SEQuential file. That's true.
-
- Unfortunately, the directory reading
-
- program listed in that manual doesn't
-
- work. Fortunately, LOADSTAR now
-
- provides you with a version that DOES
-
- work on the 1541 drive. Look for it
-
- in the directory under the name
-
- Q&D DIR DISPLAY.
-
- Here's a blow-by-blow account of how
-
- Q&D DIR DISPLAY works:
-
-
- 1020 OPEN15,8,15,"I0"
-
- We initialize the disk. It is
-
- possible that the disk we are about to
-
- read was just placed in the drive.
-
- This will help prevent DISK ID
-
- MISMATCHes in that case.
-
-
- 1030 Z$=CHR$(0): IL$=CHR$(128):
- Q$=CHR$(34): SP$=CHR$(160)
-
- We declare some variables:
-
- Z$ is used later when we evaluate
-
- ASCii value of the result of a GET#.
-
- If you GET# a ZERO character, the ASC
-
- function won't work. To prevent
-
- ILLEGAL QUANTITY ERRORs, we can
-
- concatenate Z$ to the variable we GET
-
- before we evaluate the variable:
-
- e.g. GET#8,K$:PRINT ASC(K$+Z$)
-
- Q$ is defined as the quote symbol.
-
- We use it later to bracket file names
-
- as we print them.
-
- SP$ is a shifted space. In the
-
- directory, every file name less than
-
- 16 characters long ends with
-
- shifted spaces.
-
-
- 1040 DIM F$(29)
-
- We will use array F$ to assemble
-
- file names. Each name uses 29 bytes
-
- of the directory.
-
-
- 1050 TY$(0)="DEL": TY$(1)="SEQ":
- TY$(2)="PRG": TY$(3)="USR":
- TY$(4)="REL"
-
- Here we declare file types.
-
-
- 1060 OPEN8,8,8,"$"
-
- We open the directory as a file.
-
-
- 1070 BU=0
-
- BU is our "BLOCKS USED" counter.
-
- We set it to zero before we start
-
- reading the directory.
-
-
- 1080 FOR C1=1 TO 142: GET#8,K$: NEXT
-
- The first 142 characters of the
-
- directory are not interesting to us
-
- at this point so we skip over them.
-
- (The third through 142nd characters
-
- make up the BLOCK AVAILABILITY MAP.)
-
-
-
- 1090 PRINT "NAME:<rvon>";:FOR C1=144
- TO 160: GET#8,K$:PRINT K$;: NEXT:
- PRINT"<rvof> ";
-
- The next eighteen characters of
-
- the directory are the disk name. We
-
- print that in reverse.
-
-
- 1100 GET#8,L$,M$,N$: PRINT"ID:"M$,N$
-
- We read and print the disk ID.
-
- -------< continued in Part 30 >-------
-